<?php 
 include_once dirname(__FILE__)."/config.php";
 class participants_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_ID_PAR;
		 protected $_NOM_PAR;
		 protected $_PRENOM_PAR;
		 protected $_E_MAIL_PAR;
		 protected $_TEL_PAR;
		 protected $_GRADE_PAR;
		 protected $_SPECIALITE_PAR;
		 protected $_UNIVERSITE_PAR;
		 protected $_ETABLISSEMENT_PAR;
		 public function get_name_table(){ return "participants";}
		 public function get_name_ID_PAR(){ return "ID_PAR";}
		 public function get_name_NOM_PAR(){ return "NOM_PAR";}
		 public function get_name_PRENOM_PAR(){ return "PRENOM_PAR";}
		 public function get_name_E_MAIL_PAR(){ return "E_MAIL_PAR";}
		 public function get_name_TEL_PAR(){ return "TEL_PAR";}
		 public function get_name_GRADE_PAR(){ return "GRADE_PAR";}
		 public function get_name_SPECIALITE_PAR(){ return "SPECIALITE_PAR";}
		 public function get_name_UNIVERSITE_PAR(){ return "UNIVERSITE_PAR";}
		 public function get_name_ETABLISSEMENT_PAR(){ return "ETABLISSEMENT_PAR";}
		 public function set_ID_PAR($parametre){  $this->_ID_PAR=$parametre;}	
		 public function set_NOM_PAR($parametre){  $this->_NOM_PAR=$parametre;}	
		 public function set_PRENOM_PAR($parametre){  $this->_PRENOM_PAR=$parametre;}	
		 public function set_E_MAIL_PAR($parametre){  $this->_E_MAIL_PAR=$parametre;}	
		 public function set_TEL_PAR($parametre){  $this->_TEL_PAR=$parametre;}	
		 public function set_GRADE_PAR($parametre){  $this->_GRADE_PAR=$parametre;}	
		 public function set_SPECIALITE_PAR($parametre){  $this->_SPECIALITE_PAR=$parametre;}	
		 public function set_UNIVERSITE_PAR($parametre){  $this->_UNIVERSITE_PAR=$parametre;}	
		 public function set_ETABLISSEMENT_PAR($parametre){  $this->_ETABLISSEMENT_PAR=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_ID_PAR(){ return $this->_ID_PAR;}
		 public function get_NOM_PAR(){ return $this->_NOM_PAR;}
		 public function get_PRENOM_PAR(){ return $this->_PRENOM_PAR;}
		 public function get_E_MAIL_PAR(){ return $this->_E_MAIL_PAR;}
		 public function get_TEL_PAR(){ return $this->_TEL_PAR;}
		 public function get_GRADE_PAR(){ return $this->_GRADE_PAR;}
		 public function get_SPECIALITE_PAR(){ return $this->_SPECIALITE_PAR;}
		 public function get_UNIVERSITE_PAR(){ return $this->_UNIVERSITE_PAR;}
		 public function get_ETABLISSEMENT_PAR(){ return $this->_ETABLISSEMENT_PAR;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 participants(
			NOM_PAR,
			PRENOM_PAR,
			E_MAIL_PAR,
			TEL_PAR,
			GRADE_PAR,
			SPECIALITE_PAR,
			UNIVERSITE_PAR,
			ETABLISSEMENT_PAR)
 VALUES(
			'".$this->_NOM_PAR."',
			'".$this->_PRENOM_PAR."',
			'".$this->_E_MAIL_PAR."',
			'".$this->_TEL_PAR."',
			'".$this->_GRADE_PAR."',
			'".$this->_SPECIALITE_PAR."',
			'".$this->_UNIVERSITE_PAR."',
			'".$this->_ETABLISSEMENT_PAR."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_NOM_PAR)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NOM_PAR='".$this->_NOM_PAR."'";
}
if(!empty($this->_PRENOM_PAR)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
PRENOM_PAR='".$this->_PRENOM_PAR."'";
}
if(!empty($this->_E_MAIL_PAR)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
E_MAIL_PAR='".$this->_E_MAIL_PAR."'";
}
if(!empty($this->_TEL_PAR)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
TEL_PAR='".$this->_TEL_PAR."'";
}
if(!empty($this->_GRADE_PAR)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
GRADE_PAR='".$this->_GRADE_PAR."'";
}
if(!empty($this->_SPECIALITE_PAR)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
SPECIALITE_PAR='".$this->_SPECIALITE_PAR."'";
}
if(!empty($this->_UNIVERSITE_PAR)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
UNIVERSITE_PAR='".$this->_UNIVERSITE_PAR."'";
}
if(!empty($this->_ETABLISSEMENT_PAR)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
ETABLISSEMENT_PAR='".$this->_ETABLISSEMENT_PAR."'";
}
$sql="UPDATE 
participants SET 
 ".$sql."
								WHERE ID_PAR ='".$this->_ID_PAR."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
participants 
 
									WHERE ID_PAR ='".$this->_ID_PAR."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
participants ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		ID_PAR,
		NOM_PAR,
		PRENOM_PAR,
		E_MAIL_PAR,
		TEL_PAR,
		GRADE_PAR,
		SPECIALITE_PAR,
		UNIVERSITE_PAR,
		ETABLISSEMENT_PAR
 FROM 
 participants";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_ID_PAR=$row->ID_PAR;
		$this->_NOM_PAR=$row->NOM_PAR;
		$this->_PRENOM_PAR=$row->PRENOM_PAR;
		$this->_E_MAIL_PAR=$row->E_MAIL_PAR;
		$this->_TEL_PAR=$row->TEL_PAR;
		$this->_GRADE_PAR=$row->GRADE_PAR;
		$this->_SPECIALITE_PAR=$row->SPECIALITE_PAR;
		$this->_UNIVERSITE_PAR=$row->UNIVERSITE_PAR;
		$this->_ETABLISSEMENT_PAR=$row->ETABLISSEMENT_PAR;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>